package cn.whpu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;


@Controller
@RequestMapping("/springmvc")
@SessionAttributes(value = {"username","password"},types = {Integer.class})
public class SessionAttributeController {
    /**
     * 把数据存入SessionAttribute
     * @param model
     * @return
     */
    @RequestMapping("/testPut")
    public String testPut(Model model){
        model.addAttribute("username","吱吱吱吱");
        model.addAttribute("password","123445");
        model.addAttribute("age",34);
        return "success";
    }
    @RequestMapping("/testGet")
    public String testGet(ModelMap modelMap){
        System.out.println(modelMap.get("username")+";"+
                modelMap.get("password")+";"+
                modelMap.get("age"));
        return "success";
    }

    @RequestMapping("/testClean")
    public String complete(SessionStatus sessionStatus){
        sessionStatus.setComplete();
        return "success";
    }
}
